import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JScrollBar;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * This class is admin UI
 */
public class AdminUI extends JPanel {
	/**
	 * title for the current window  
	 */
	private JLabel lbltitle = null;
	/**
	 * button for add student 
	 */
	private JButton btnAddStudent = null;
	/**
	 * button for add parent 
	 */
	private JButton btnAddParent = null;
	/**
	 * button for add teacher 
	 */
	private JButton btnAddTeacher = null;
	/**
	 * back button 
	 */
	public JButton btnBack = null;
	/**
	 * help button
	 */
	public JButton btnHelp = null;
	/**
	 * save the current panel for the "back" function 
	 */
	private JPanel curPanel;
	/**
	* Constructs 
	*/
	public AdminUI () {
		super();
		initialize();
	}

	private void initialize() {
		curPanel = this;
		btnAddStudent = new JButton();
		/**
		 *  add student Implementation
		 */
		btnAddStudent.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				AddUserUI add = new AddUserUI(4);
				setVisible(false);
				System.out.println("now loged Admin");
				add.setVisible(true);
				Global.main.setContentPane(add);
				/**
				 *  back button Implementation
				 */
				add.btnBack.addActionListener(new ActionListener() {  
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnAddStudent.setBounds(new Rectangle(130, 73, 200, 25));
		btnAddStudent.setText("Add/Delete Student");
		this.add(btnAddStudent,null);
		this.setVisible(true);
		
		btnAddParent = new JButton();
		/**
		 *  add parent Implementation
		 */
		btnAddParent.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				AddParentUI addParent = new AddParentUI();
				setVisible(false);
				System.out.println("Add/Delete Parent");
				Global.main.setContentPane(addParent);
				/**
				 *  back button Implementation
				 */
				addParent.btnBack.addActionListener(new ActionListener() {   //back from addParent UI
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnAddParent.setBounds(new Rectangle(130, 136, 200, 25));
		btnAddParent.setText("Add/Delete Parent");
		this.add(btnAddParent,null);
		this.setVisible(true);
		
		btnAddTeacher = new JButton();
		/**
		 *  add teacher Implementation
		 */
		btnAddTeacher.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				AddUserUI add = new AddUserUI(6);
				setVisible(false);
				System.out.println("Add/Delete Teacher");
				Global.main.setContentPane(add);
				/**
				 *  back button Implementation
				 */
				add.btnBack.addActionListener(new ActionListener() {   //back from add user UI
					public void actionPerformed(ActionEvent arg0) {
						Global.main.setContentPane(curPanel);
						curPanel.setVisible(true);
					}
				});
			}
		});
		btnAddTeacher.setBounds(new Rectangle(130, 198, 200, 25));
		btnAddTeacher.setText("Add/Delete Teacher");
		this.add(btnAddTeacher,null);
		this.setVisible(true);

		lbltitle = new JLabel("Admin Log In");
		lbltitle.setBounds(193, 28, 110, 14);

		this.setSize(400, 321);
		this.setLayout(null);
		
		this.add(lbltitle);
	
		btnBack = new JButton("Back");
		btnBack.setBounds(187, 253, 86, 25);
		this.add(btnBack,null);
		this.setVisible(true);
		/**
		 *  help button Implementation
		 */
		btnHelp = new JButton("Help");
		btnHelp.setBounds(390, 11, 80, 19);
		btnHelp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				  HelpWin help = new HelpWin ("Click on one of the option");
				  System.out.println("user press Help button");
			}
		});
		this.add(btnHelp,null);
		this.setVisible(true);
		
	}
			
			
}
